import '../styles/index.css';
import TodoForm from '../components/TodoForm';
import TodoItem from '../components/TodoItem';

//通过函数返回一个组件 参数todoList是异步请求后的列表数据
export default function Home(todoList) {
  // console.log(todoList);
  //[{_id: '6409d2d86f05761c0dbf0dc1', title: '111', content: '111', completed: false, createdAt: '2023-03-09T12:36:40.718Z', …}]
  return `<div>
    <!-- TodoForm表单 -->
    ${TodoForm()}
    <!-- TodoList列表 -->
    <ul id="list">
      ${todoList.map((todo) => TodoItem(todo)).join('')}
    </ul>
  </div>`;
}
